package com.example.springiocdi;

import com.example.springiocdi.Controller.HelloController;
import com.example.springiocdi.Service.UserService;
import com.example.springiocdi.model.Student;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;

//配置扫描路径
//@ComponentScan("com.example")
//@ComponentScan({"com.example.springiocdi.component","com.example.springiocdi.config"})

@SpringBootApplication
public class SpringIocDiApplication {

    public static void main(String[] args) {
        ApplicationContext context= SpringApplication.run(SpringIocDiApplication.class, args);
//        HelloController bean1=context.getBean(HelloController.class);
//bean1.print();
//        HelloController bean2= (HelloController) context.getBean("helloController");
//        HelloController bean3=context.getBean("helloController", HelloController.class);
//        System.out.println(bean1);
//        System.out.println(bean2);
//        System.out.println(bean3);

//        HController bean1=context.getBean(HController.class);
//        bean1.print();
//HController bean2= (HController) context.getBean("HController");
//bean2.print();
//HController bean3=context.getBean("HController", HController.class);
//bean3.print();
//        System.out.println(bean1);
//        System.out.println(bean2);
//        System.out.println(bean3);


//        UserService bean1=context.getBean(UserService.class);
//        bean1.print();
//        UserService bean2= (UserService) context.getBean("userService");
//        bean2.print();
//        UserService bean3=context.getBean("userService", UserService.class);
//bean3.print();
//        System.out.println(bean1);
//        System.out.println(bean2);
//        System.out.println(bean3);

//        UserConfig bean= (UserConfig) context.getBean("aaaa");
//bean.print();

//        Student s1= (Student) context.getBean("s5");
//        System.out.println(s1);

//
//        HelloController bean=context.getBean(HelloController.class);
//        bean.print();

        UserService bean1 = context.getBean(UserService.class);
        bean1.print();

    }

}
